/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.ui.dialogs;

import java.util.Iterator;
import java.util.List;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;

import com.cea.papyrus.core.utils.Debug;
import com.cea.papyrus.core.utils.LookForElement;


/**
 * 
 */
public class ChooseTemplateParameterKindDialog extends ChooseDialog  implements IChooseDialog {
	
	/**
	 * 
	 */
	List allTypes;
	
	/**
	 * 
	 */
	Package model;
	
//	/**
//	 * 
//	 * 
//	 * @param parentShell 
//	 * @param model 
//	 */
//	public ChooseTemplateParameterKindDialog(Shell parentShell,Package model){
//		super(parentShell);
//		this.model=model;
//		announce="Choose your MetaClass:";
//		allTypes=LookForElement.getMetaclasses();
//		
//		
//		elementList = new String[allTypes.size()];
//		
//		Iterator it = allTypes.iterator();
//		int i=0;
//
//		while( it.hasNext()){
//			NamedElement ne=((NamedElement)it.next());
//			elementList[i]=ne.getName()+"      ["+ ne.getQualifiedName()+"]";
//			i++;
//		}
//	}
		
	public ChooseTemplateParameterKindDialog(Shell parentShell){
		super(parentShell);
		announce="Choose the kind of TemplateParameter:";
		allTypes=LookForElement.getMetaclasses(UMLPackage.eINSTANCE.getTemplateParameter(),false, null);
		
		elementList = new String[allTypes.size()];
		
		Iterator it = allTypes.iterator();
		int i=0;
		
		while( it.hasNext()){
			NamedElement ne=(NamedElement)it.next();
			elementList[i]=ne.getName()+"      ["+ ne.getQualifiedName()+"]";
			i++;
		}

	}
	
	/**
	 * 
	 * 
	 * @param parent 
	 * 
	 * @return 
	 */
	@Override
	protected Control createDialogArea(Composite parent){
		Composite comp=(Composite)super.createDialogArea(parent);
		return comp;
	}
	
	/**
	 * 
	 * 
	 * @param parent 
	 */
	@Override
	protected void createButtonsForButtonBar(Composite parent){
		super.createButtonsForButtonBar(parent);
		
	}
	
	/**
	 * 
	 * 
	 * @param buttonId 
	 */
	@Override
	protected void buttonPressed(int buttonId){
		super.buttonPressed(buttonId);
	}
	
	/**
	 * 
	 */
	@Override
	protected void okPressed(){
		Debug.debug(this,"ChooseDialog.okPressed "+combo.getSelectionIndex(), channel);
		int i=combo.getSelectionIndex();
		value=allTypes.get(i);
//		org.eclipse.uml2.uml.Class metaclass= (org.eclipse.uml2.uml.Class)allTypes.get(i);
//		Debug.debug(this,"metaclass"+metaclass, channel);
//		Debug.debug(this,"model"+((Profile)model).getReferencedMetaclasses(), channel);
//	    ((Profile)model).createMetaclassReference(metaclass);
		
		
		super.okPressed();
	}

}
